<template>

  <div class="app-container">
    <el-card class="box-card">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<!--      <el-form-item label="产品名称" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品型号" prop="productModel">
        <el-input
          v-model="queryParams.productModel"
          placeholder="请输入产品型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品编码" prop="productCode">
        <el-input
          v-model="queryParams.productCode"
          placeholder="请输入产品编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品图例" prop="productLegend">
        <el-input
          v-model="queryParams.productLegend"
          placeholder="请输入产品图例"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品数量" prop="productQuantity">
        <el-input
          v-model="queryParams.productQuantity"
          placeholder="请输入产品数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="零件名称" prop="partName">
        <el-input
          v-model="queryParams.partName"
          placeholder="请输入零件名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="适用机型" prop="applicableModel">
        <el-input
          v-model="queryParams.applicableModel"
          placeholder="请输入适用机型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="零件图号" prop="drawingNum">
        <el-input
          v-model="queryParams.drawingNum"
          placeholder="请输入零件图号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="零件编码" prop="partNumber">
        <el-input
          v-model="queryParams.partNumber"
          placeholder="请输入零件编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订货数量" prop="orderQuantity">
        <el-input
          v-model="queryParams.orderQuantity"
          placeholder="请输入订货数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
<!--      <el-form-item label="计量单位" prop="measurementUnit">
        <el-input
          v-model="queryParams.measurementUnit"
          placeholder="请输入计量单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区分状态" prop="differentiateStates">
        <el-input
          v-model="queryParams.differentiateStates"
          placeholder="请输入区分状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="涉及承制单位" prop="unitsInvolved">
        <el-input
          v-model="queryParams.unitsInvolved"
          placeholder="请输入涉及承制单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="军代表室" prop="representativeOffice">
        <el-input
          v-model="queryParams.representativeOffice"
          placeholder="请输入军代表室"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="问题类别" prop="problemCategory">
        <el-select
          v-model="queryParams.problemCategory"
          placeholder="请输入问题类别"
          clearable
          @keyup.enter.native="handleQuery"
        >
          <el-option
            v-for="dict in dict.type.yh_problem_category"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="发生时间" prop="occurrence">
        <el-date-picker clearable
                        v-model="queryParams.occurrence"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择发生时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="涉及装备" prop="involvedEquipment">
        <el-input
          v-model="queryParams.involvedEquipment"
          placeholder="请输入涉及装备"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人" prop="head">
        <el-input
          v-model="queryParams.head"
          placeholder="请输入负责人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计量单位" prop="measurementUnit" v-show="showSearch">
        <el-select
          style="width: 100%"
          v-model="queryParams.measurementUnit"
          placeholder="请输入计量单位"
          clearable
        >
          <el-option
            v-for="dict in dict.type.yh_measurement_unit"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="原因分析" prop="causeAnalysis">
        <el-input
          v-model="queryParams.causeAnalysis"
          placeholder="请输入原因分析"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="解决进展" prop="resolutionProgress">
        <el-input
          v-model="queryParams.resolutionProgress"
          placeholder="请输入解决进展"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="问题整改计划时限" prop="problemRectification">
        <el-input
          v-model="queryParams.problemRectification"
          placeholder="请输入问题整改计划时限"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
<!--      <el-form-item label="创建者" prop="createBy">
        <el-input
          v-model="queryParams.createBy"
          placeholder="请输入创建者"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        <el-date-picker clearable
          v-model="queryParams.createTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="更新者" prop="updateBy">
        <el-input
          v-model="queryParams.updateBy"
          placeholder="请输入更新者"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="更新时间" prop="updateTime">
        <el-date-picker clearable
          v-model="queryParams.updateTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择更新时间">
        </el-date-picker>
      </el-form-item>-->
      <br/>
      <div style="text-align: right;">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </div>
      <br/>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['dr:issues:add']"
        >新增</el-button>
      </el-col>
<!--      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['dr:issues:edit']"
        >修改</el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['dr:issues:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['dr:issues:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" border :data="issuesList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        label="序号"
        type="index"
        width="50"
        align="center">
        <template scope="scope">
          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="产品名称" align="center" prop="productName" v-if="columns[0].visible"/>
      <el-table-column label="产品类型" align="center" prop="productType" v-if="columns[1].visible"/>
      <el-table-column label="产品型号" align="center" prop="productModel" v-if="columns[2].visible"/>
      <el-table-column label="产品编码" align="center" prop="productCode" v-if="columns[3].visible"/>
      <el-table-column label="产品图例" align="center" prop="productLegend" v-if="columns[4].visible"/>
      <el-table-column label="产品数量" align="center" prop="productQuantity" v-if="columns[5].visible"/>
      <el-table-column label="零件名称" align="center" prop="partName" v-if="columns[6].visible"/>
      <el-table-column label="零件类型" align="center" prop="partType" v-if="columns[7].visible"/>
      <el-table-column label="适用机型" align="center" prop="applicableModel" v-if="columns[8].visible"/>
      <el-table-column label="零件图号" align="center" prop="drawingNum" v-if="columns[9].visible"/>
      <el-table-column label="零件编码" align="center" prop="partNumber" v-if="columns[10].visible"/>
      <el-table-column label="订货数量" align="center" prop="orderQuantity" v-if="columns[11].visible"/>
      <el-table-column label="计量单位" align="center" prop="measurementUnit" v-if="columns[12].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_measurement_unit" :value="scope.row.measurementUnit"/>
        </template></el-table-column>
      <el-table-column label="区分状态" align="center" prop="differentiateStates" v-if="columns[13].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_differentiate_states" :value="scope.row.differentiateStates"/>
        </template></el-table-column>
      <el-table-column label="发生时间" align="center" prop="occurrence" width="180" v-if="columns[14].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.occurrence, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="涉及装备" align="center" prop="involvedEquipment" v-if="columns[15].visible"/>
      <el-table-column label="简要情况" align="center" prop="briefSituation" v-if="columns[16].visible"/>
      <el-table-column label="涉及承制单位" align="center" prop="unitsInvolved" v-if="columns[17].visible"/>
      <el-table-column label="军代表室" align="center" prop="representativeOffice" v-if="columns[18].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_representative_office" :value="scope.row.representativeOffice"/>
        </template>
      </el-table-column>
      <el-table-column label="问题类别" align="center" prop="problemCategory" v-if="columns[19].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_problem_category" :value="scope.row.problemCategory"/>
        </template></el-table-column>
      <el-table-column label="负责人" align="center" prop="head" v-if="columns[20].visible"/>
      <el-table-column label="原因分析" align="center" prop="causeAnalysis" v-if="columns[21].visible"/>
      <el-table-column label="解决进展" align="center" prop="resolutionProgress" v-if="columns[22].visible"/>
      <el-table-column label="问题整改计划时限" align="center" prop="problemRectification" v-if="columns[23].visible"/>
      <el-table-column label="质量问题类型" align="center" prop="qualityIssuesType" v-if="columns[24].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_quality_issues_type" :value="scope.row.qualityIssuesType"/>
        </template></el-table-column>
<!--      <el-table-column label="创建者" align="center" prop="createBy" v-if="columns[25].visible"/>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180" v-if="columns[26].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新者" align="center" prop="updateBy" v-if="columns[27].visible"/>
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180" v-if="columns[28].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>-->
      <el-table-column label="备注" align="center" prop="remark" v-if="columns[25].visible"/>
<!--      <el-table-column label="备注1" align="center" prop="note1" />
      <el-table-column label="备注2" align="center" prop="note2" />
      <el-table-column label="备注3" align="center" prop="note3" />
      <el-table-column label="备注4" align="center" prop="note4" />
      <el-table-column label="备注5" align="center" prop="note5" />
      <el-table-column label="备注6" align="center" prop="note6" />
      <el-table-column label="备注7" align="center" prop="note7" />
      <el-table-column label="备注8" align="center" prop="note8" />
      <el-table-column label="备注9" align="center" prop="note9" />
      <el-table-column label="备注10" align="center" prop="note10" />-->
      <el-table-column label="操作"  fixed="right" width="180px" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['dr:issues:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleProgress(scope.row)"
            v-hasPermi="['dr:issues:progress']"
          >进展</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleView(scope.row)"
            v-hasPermi="['dr:issues:query']"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleDelete(scope.row)"
            v-hasPermi="['dr:issues:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>
    <!-- 添加或修改质量问题对话框 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 18px;">问题划分</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-col :span="8">
            <el-form-item label="所属问题">
              <el-radio-group v-model="radio1" >
                <el-radio label="1">产品问题</el-radio>
                <el-radio label="2">零件问题</el-radio>
                <el-col span="12" style="display: none">
                  <el-form-item label="note1" prop="note1">
                    <el-input v-model="form.note1=this.radio1"></el-input>
                  </el-form-item>
                </el-col>
              </el-radio-group>
            </el-form-item>
            </el-col>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-col :span="24" v-if="this.radio1 == '1'" >
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 18px;">产品问题</p>
            </el-divider>
            </el-col>
            <el-col :span="24" v-if="this.radio1  == '2'" >
              <el-divider content-position="left">
                <p style="color: #00afff; font-size: 18px;">零件问题</p>
              </el-divider>
            </el-col>
          </el-header>
          <el-main>
            <el-col :span="8"  v-if="this.radio1  == '1'">
              <el-form-item label="产品名称"prop="productName">
                <el-autocomplete
                  style="width: 100%"
                  placeholder="请输入产品名称"
                  v-model="form.productName"
                  :fetch-suggestions="querySearchAsync"
                  @select="handleSelect"
                >
                </el-autocomplete>
              </el-form-item>

            </el-col>
              <el-col :span="8"  v-if="this.radio1  == '1'">
              <el-form-item label="产品图例" prop="productLegend" style="display: none">
                <el-input v-model="form.productLegend" placeholder="请输入产品图例" />
              </el-form-item>
<!--              <el-form-item label="产品数量" prop="productQuantity">
                <el-input v-model="form.productQuantity" placeholder="请输入产品数量" />
              </el-form-item>-->
            </el-col>
            <el-col :span="8"  v-if="this.radio1  == '1'">
            <el-form-item label="产品编码" prop="productCode">
              <el-input v-model="form.productCode" placeholder="请输入产品编码" />
            </el-form-item>
            </el-col>
            <el-col :span="8"  v-if="this.radio1  == '1'">
            <el-form-item label="产品型号" prop="productModel">
              <el-input v-model="form.productModel" placeholder="请输入产品型号" />
            </el-form-item>
            </el-col>
            <el-col :span="8"  v-if="this.radio1  == '2'">
              <el-form-item label="零件名称" prop="partName">
                <el-autocomplete
                  style="width: 100%"
                  placeholder="请输入零件名称"
                  v-model="form.partName"
                  :fetch-suggestions="querySearchAsync1"
                  @select="handleSelect1"
                >
                </el-autocomplete>
              </el-form-item>
              <el-form-item label="适用机型" prop="applicableModel">
                <el-input v-model="form.applicableModel" placeholder="请输入适用机型" />
              </el-form-item>
            </el-col>
            <el-col :span="8"  v-if="this.radio1  == '2'">
              <el-form-item label="零件图号" prop="drawingNum">
                <el-input v-model="form.drawingNum" placeholder="请输入零件图号" />
              </el-form-item>
<!--              <el-form-item label="订货数量" prop="orderQuantity">
                <el-input v-model="form.orderQuantity" placeholder="请输入订货数量" />
              </el-form-item>-->
            </el-col>
            <el-col :span="8"  v-if="this.radio1  == '2'">
              <el-form-item label="零件编码" prop="partNumber">
                <el-input v-model="form.partNumber" placeholder="请输入零件编码" />
              </el-form-item>

            </el-col>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 18px;">问题详情</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-col :span="8">
              <el-form-item label="问题类别" prop="problemCategory">
                <el-select
                  style="width: 100%"
                  v-model="form.problemCategory"
                  placeholder="请输入问题类别"
                  clearable
                >
                  <el-option
                    v-for="dict in dict.type.yh_problem_category"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="原因分析" prop="causeAnalysis">
                <el-input v-model="form.causeAnalysis" placeholder="请输入原因分析" style="width: 100%"/>
              </el-form-item>
            <el-form-item label="计量单位" prop="measurementUnit">
                <el-select
                  style="width: 100%"
                  v-model="form.measurementUnit"
                  placeholder="请输入计量单位"
                  clearable
                >
                  <el-option
                    v-for="dict in dict.type.yh_measurement_unit"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
            </el-form-item>
              <el-form-item label="质量问题类型" prop="qualityIssuesType">
                <el-select
                  style="width: 100%"
                  v-model="form.qualityIssuesType"
                  placeholder="请输入质量问题类型"
                  clearable
                >
                  <el-option
                    v-for="dict in dict.type.yh_quality_issues_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>

            </el-col>
              <el-col :span="8">

            <el-form-item label="涉及装备" prop="involvedEquipment">
              <el-input v-model="form.involvedEquipment" placeholder="请输入涉及装备" style="width: 100%"/>
            </el-form-item>
                <el-form-item label="区分状态" prop="differentiateStates">
                  <el-select
                    style="width: 100%"
                    v-model="form.differentiateStates"
                    placeholder="请输入区分状态"
                    clearable
                  >
                    <el-option
                      v-for="dict in dict.type.yh_differentiate_states"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
                </el-form-item>
            <el-form-item label="涉及承制单位" prop="unitsInvolved">
              <el-input v-model="form.unitsInvolved" placeholder="请输入涉及承制单位" style="width: 100%"/>
            </el-form-item>
              </el-col>
            <el-col :span="8">
              <el-form-item label="军代表室"  prop="representativeOffice">
                <el-select v-model="form.representativeOffice" placeholder="请选择部门" style="width:90%;float:left">
                  <el-option
                    v-for="dict in dict.type.yh_representative_office"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            <el-form-item label="负责人" prop="head">
              <el-input v-model="form.head" placeholder="请输入负责人" style="width: 100%"/>
            </el-form-item>
              <el-form-item label="发生时间" prop="occurrence">
                <el-date-picker clearable
                                style="width: 100%"
                                v-model="form.occurrence"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="请选择发生时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
            <el-form-item label="简要情况" prop="briefSituation">
              <el-input v-model="form.briefSituation" type="textarea" placeholder="请输入内容" style="width: 100%"/>
            </el-form-item>
              <el-form-item label="备注" prop="remark">
                <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" style="width: 100%"/>
              </el-form-item>
            </el-col>
          </el-main>
        </el-container>
<!--        <el-form-item label="解决进展" prop="resolutionProgress">
          <el-input v-model="form.resolutionProgress" placeholder="请输入解决进展" />
        </el-form-item>
        <el-form-item label="问题整改计划时限" prop="problemRectification">
          <el-input v-model="form.problemRectification" placeholder="请输入问题整改计划时限" />
        </el-form-item>-->
<!--        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入产品名称" />
        </el-form-item>
        <el-form-item label="产品型号" prop="productModel">
          <el-input v-model="form.productModel" placeholder="请输入产品型号" />
        </el-form-item>
        <el-form-item label="产品编码" prop="productCode">
          <el-input v-model="form.productCode" placeholder="请输入产品编码" />
        </el-form-item>
        <el-form-item label="产品图例" prop="productLegend">
          <el-input v-model="form.productLegend" placeholder="请输入产品图例" />
        </el-form-item>
        <el-form-item label="产品数量" prop="productQuantity">
          <el-input v-model="form.productQuantity" placeholder="请输入产品数量" />
        </el-form-item>
        <el-form-item label="零件名称" prop="partName">
          <el-input v-model="form.partName" placeholder="请输入零件名称" />
        </el-form-item>
        <el-form-item label="适用机型" prop="applicableModel">
          <el-input v-model="form.applicableModel" placeholder="请输入适用机型" />
        </el-form-item>
        <el-form-item label="零件图号" prop="drawingNum">
          <el-input v-model="form.drawingNum" placeholder="请输入零件图号" />
        </el-form-item>
        <el-form-item label="零件编码" prop="partNumber">
          <el-input v-model="form.partNumber" placeholder="请输入零件编码" />
        </el-form-item>
        <el-form-item label="订货数量" prop="orderQuantity">
          <el-input v-model="form.orderQuantity" placeholder="请输入订货数量" />
        </el-form-item>

-->

<!--        <el-form-item label="备注1" prop="note1">
          <el-input v-model="form.note1" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注2" prop="note2">
          <el-input v-model="form.note2" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注3" prop="note3">
          <el-input v-model="form.note3" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注4" prop="note4">
          <el-input v-model="form.note4" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注5" prop="note5">
          <el-input v-model="form.note5" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注6" prop="note6">
          <el-input v-model="form.note6" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注7" prop="note7">
          <el-input v-model="form.note7" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注8" prop="note8">
          <el-input v-model="form.note8" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注9" prop="note9">
          <el-input v-model="form.note9" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注10" prop="note10">
          <el-input v-model="form.note10" type="textarea" placeholder="请输入内容" />
        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改质量问题对话框 -->
   <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open1" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <main>
                <el-form-item label="问题整改计划时限" prop="problemRectification">
                  <el-input v-model="form.problemRectification" placeholder="请输入问题整改计划时限" />
                </el-form-item>
        </main>
        <main>
          <el-form-item label="解决进展" prop="resolutionProgress">
            <el-input v-model="form.resolutionProgress" type="textarea" placeholder="请输入解决进展" />
          </el-form-item>
        </main>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="ProgressForm">确 定</el-button>
        <el-button @click="cancelProgress">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<style>
.ql-toolbar.ql-snow {
  text-align: left;
  border: 1px solid #ccc;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
  padding: 8px;
  /* float: none; */
}
.el-header, .el-footer {
  background-color: #FFFFFF;
  color: #333;
  text-align: left;
  line-height: 60px;
  font-style: oblique;

}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #FFFFFF;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

/*对话框标题样式*/
.el-dialog__title{
  /*color: #1ab394;*/
  font-weight: bold;
  font-size: 25px;
}
</style>
<script>
import { listIssues, getIssues, delIssues, addIssues, updateIssues ,updateIssuesProgress} from "@/api/module/dr/issues";
import { listProduct} from "@/api/module/dr/product";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import watermark from "watermark-dom";

export default {
  name: "Issues",
  dicts:['yh_measurement_unit','yh_quality_issues_type','yh_problem_category','yh_differentiate_states','yh_representative_office'],
  components: {Treeselect},
  mounted() {
    // 加载水印
    const username = this.$store.state.user.name;
    watermark.load({watermark_txt: "  "});
  },
  data() {
    return {
      // 基础信息表格数据
      productList: [],
      radio1: "1",
      columns: [
        {key: 0, label: `产品名称`, visible: false},
        {key: 1, label: `产品类型`, visible: false},
        {key: 2, label: `产品型号`, visible: false},
        {key: 3, label: `产品编码`, visible: false},
        {key: 4, label: `产品图例`, visible: false},
        {key: 5, label: `产品数量`, visible: false},
        {key: 6, label: `零件名称`, visible: false},
        {key: 7, label: `零件类型`, visible: false},
        {key: 8, label: `适用机型`, visible: false},
        {key: 9, label: `零件图号`, visible: false},
        {key: 10, label: `零件编码`, visible: false},
        {key: 11, label: `订货数量`, visible: false},
        {key: 12, label: `计量单位`, visible: false},
        {key: 13, label: `区分状态`, visible: false},
        {key: 14, label: `发生时间`, visible: true},
        {key: 15, label: `涉及装备`, visible: false},
        {key: 16, label: `简要情况`, visible: false},
        {key: 17, label: `涉及承制单位`, visible: true},
        {key: 18, label: `军代表室`, visible: true},
        {key: 19, label: `问题类别`, visible: true},
        {key: 20, label: `负责人`, visible: true},
        {key: 21, label: `原因分析`, visible: false},
        {key: 22, label: `解决进展`, visible: false},
        {key: 23, label: `问题整改计划时限`, visible: false},
        {key: 24, label: `质量问题类型`, visible: false},
        {key: 25, label: `备注`, visible: true},
      ],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 质量问题表格数据
      issuesList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open1: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        productName: null,
        productType: null,
        productModel: null,
        productCode: null,
        productLegend: null,
        productQuantity: null,
        partName: null,
        partType: null,
        applicableModel: null,
        drawingNum: null,
        partNumber: null,
        orderQuantity: null,
        measurementUnit: null,
        differentiateStates: null,
        occurrence: null,
        involvedEquipment: null,
        briefSituation: null,
        unitsInvolved: null,
        representativeOffice: null,
        problemCategory: null,
        head: null,
        causeAnalysis: null,
        resolutionProgress: null,
        problemRectification: null,
        qualityIssuesType: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        measurementUnit: [
          {required: true, message: "计量单位不能为空", trigger: "blur"}
        ],
        productName: [
          {required: true, message: "产品名称不能为空", trigger: "blur"}
        ],
        productModel: [
          {required: true, message: "产品型号不能为空", trigger: "blur"}
        ],
        productCode: [
          {required: true, message: "产品编码不能为空", trigger: "blur"}
        ],
        partName: [
          {required: true, message: "零件名称不能为空", trigger: "blur"}
        ],
        applicableModel: [
          {required: true, message: "适用机型不能为空", trigger: "blur"}
        ],
        drawingNum: [
          {required: true, message: "零件图号不能为空", trigger: "blur"}
        ],
        partNumber: [
          {required: true, message: "零件编码不能为空", trigger: "blur"}
        ],
        problemCategory: [
          {required: true, message: "问题类别不能为空", trigger: "blur"}
        ],
        causeAnalysis: [
          {required: true, message: "原因分析不能为空", trigger: "blur"}
        ],
        involvedEquipment: [
          {required: true, message: "涉及装备不能为空", trigger: "blur"}
        ],
        differentiateStates: [
          {required: true, message: "区分状态不能为空", trigger: "blur"}
        ],
        unitsInvolved: [
          {required: true, message: "涉及承制单位不能为空", trigger: "blur"}
        ],
        representativeOffice: [
          {required: true, message: "军代表室不能为空", trigger: "blur"}
        ],
        head: [
          {required: true, message: "负责人不能为空", trigger: "blur"}
        ],
        occurrence: [
          {required: true, message: "发生时间不能为空", trigger: "blur"}
        ],
        briefSituation: [
          {required: true, message: "简要情况不能为空", trigger: "blur"}
        ],
        resolutionProgress: [
          {required: true, message: "解决进展不能为空", trigger: "blur"}
        ],
        problemRectification: [
          {required: true, message: "问题整改计划时限不能为空", trigger: "blur"}
        ],
        qualityIssuesType: [
          {required: true, message: "质量问题类型不能为空", trigger: "blur"}
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getProduct();
    this.getTreeselect();
  },
  methods: {
    getProduct() {
      listProduct().then(response => {
        this.productList = response.rows;
      });
    },
    //queryString 为在框中输入的值
    //cb 回调函数，将处理好的数据推回
    querySearchAsync(queryString, cb) {
      let productJson = JSON.parse(JSON.stringify(this.productList).replace(/productName/g, "value"));
      let results = queryString ? productJson.filter(this.createStateFilter(queryString)) : productJson;
      clearTimeout(this.timeout);
      this.timeout = setTimeout(() => {
        cb(results);
      }, 0.5 * 1000);
    },
    //根据输入的字段进行筛选
    createStateFilter(queryString) {
      return (state) => {
        return (state.value.toString().toLowerCase().indexOf(queryString.toLowerCase()) === 0);
      };
    },

    //将其他数据自动补全，采用覆盖的方法
    handleSelect(item) {
      this.form.productName = item.value;
      this.form.productCode = item.productCode;
      this.form.productModel = item.productModel;
      this.form.productLegend = item.productLegend;
      this.form.productQuantity = item.productQuantity;
    },

    //queryString 为在框中输入的值
    //cb 回调函数，将处理好的数据推回
    querySearchAsync1(queryString, cb) {
      let productJson = JSON.parse(JSON.stringify(this.productList).replace(/partName/g, "value"));
      let results = queryString ? productJson.filter(this.createStateFilter1(queryString)) : productJson;
      clearTimeout(this.timeout);
      this.timeout = setTimeout(() => {
        cb(results);
      }, 0.5 * 1000);
    },
    //根据输入的字段进行筛选
    createStateFilter1(queryString) {
      return (state) => {
        return (state.value.toString().toLowerCase().indexOf(queryString.toLowerCase()) === 0);
      };
    },

    //将其他数据自动补全，采用覆盖的方法
    handleSelect1(item) {
      this.form.partName = item.value;
      this.form.applicableModel = item.applicableModel;
      this.form.drawingNum = item.drawingNum;
      this.form.partNumber = item.partNumber;
      this.form.orderQuantity = item.orderQuantity;
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    /** 查询质量问题列表 */
    getList() {
      this.loading = true;
      listIssues(this.queryParams).then(response => {
        this.issuesList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    cancelProgress() {
      this.open1 = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        productName: null,
        productType: null,
        productModel: null,
        productCode: null,
        productLegend: null,
        productQuantity: null,
        partName: null,
        partType: null,
        applicableModel: null,
        drawingNum: null,
        partNumber: null,
        orderQuantity: null,
        measurementUnit: null,
        differentiateStates: null,
        occurrence: null,
        involvedEquipment: null,
        briefSituation: null,
        unitsInvolved: null,
        representativeOffice: null,
        problemCategory: null,
        head: null,
        causeAnalysis: null,
        resolutionProgress: null,
        problemRectification: null,
        qualityIssuesType: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加质量问题";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getIssues(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改质量问题";
      });
    },
    /** 进展按钮操作 */
    handleProgress(row) {
      this.reset();
      const id = row.id || this.ids
      getIssues(id).then(response => {
        this.form = response.data;
        this.open1 = true;
        this.title = "问题处理进展";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateIssues(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addIssues(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 进展按钮 */
    ProgressForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateIssuesProgress(this.form).then(response => {
              this.$modal.msgSuccess("提交成功");
              this.open1 = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除？').then(function() {
        return delIssues(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 详情按钮操作 */
    handleView(row) {
      const id = row.id;
      this.$router.push({ path:"/hetong/drissuesdetail", query: {id}});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('dr/issues/export', {
        ...this.queryParams
      }, `issues_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
